package com.spring.controller.work.data;

import com.spring.controller.BaseController;
import com.util.FastJsonUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.Map;

/**
 * @author: chenhs
 * @date: Created in 16:15 2019/8/8
 **/
@Controller
public class Param2Controller extends BaseController {

    /**
     * 跳转页面
     *
     * @return
     */
    @RequestMapping
    public ModelAndView toParam2() {
        return new ModelAndView("/param/param2");
    }

    @RequestMapping
    public ModelAndView toParam3() {
        return new ModelAndView("/param/param3");
    }

    /**
     * 第一种ajax请求对应的后台接口
     * @param map
     */
    @RequestMapping("search_data_detail")
    @ResponseBody
    public void searchInfo(@RequestParam Map<String,String> map){

        Map<String, Object> jsonMap= FastJsonUtils.json2map(map.get("jsonData"));
        System.out.println("****************This is search_data_detail****************");
        for (Map.Entry<String,Object> entry:jsonMap.entrySet()){
            System.out.print("得到键为：==="+entry.getKey());
            System.out.println("得到值为：==="+entry.getValue());
        }

    }

    /**
     * 第二种ajax请求后台对应的后台接口
     * @param map
     */
    @RequestMapping("search_data_detail2")
    @ResponseBody
    public void searchInfo2(@RequestBody Map<String,String> map)  {
        System.out.println("****************This is search_data_detail2****************");
        for (Map.Entry<String,String> entry:map.entrySet()){
            System.out.print("得到键为：==="+entry.getKey());
            System.out.println("得到值为：==="+entry.getValue());
        }
    }


}
